<template>
  <div class="mainpg">
    <div class="main_spac1" style="padding-bottom: 5px">
      <div class="main_white padding10">
        <div class="mainor_form">
          <div class="mainor_te"></div>
          <el-form
            :inline="true"
            :model="form"
            class="demo-form-inline"
            ref="userListFrom"
            label-width="70px"
          >
            <el-form-item label="配送日期" prop="send_time">
              <el-date-picker
                v-model="form.send_time"
                type="date"
                class="wid220"
                :editable="false"
                placeholder="选择配送日期"
                value-format="yyyy-MM-dd"
                :clearable="false"
              />
            </el-form-item>
            <el-form-item label="线路名称" prop="line">
              <el-input
                v-model.trim="form.line"
                placeholder="线路名称"
                clearable
                class="wid220"
              ></el-input>
            </el-form-item>
            <el-form-item class>
              <el-button
                class="reset marginLeft10"
                type="primary"
                @click="$refs['userListFrom'].resetFields()"
                >重置</el-button
              >
              <el-button
                type="primary"
                @click="getArticleList"
                :loading="listLoading"
                >搜索</el-button
              >
            </el-form-item>
          </el-form>
        </div>
        <div class="main_table" style="min-height: 640px">
          <el-table
            ref="multipleTable"
            v-loading="listLoading"
            :data="list.list.data"
            element-loading-text="加载中"
            fit
            highlight-current-row
          >
            <el-table-column type="expand" class-name="main_hei">
              <template slot-scope="prop">
                <el-table
                  :ref="'expandchild' + prop.$index"
                  :data="prop.row.order_list"
                  class="mainex_ta"
                  fit
                  :highlight-current-row="false"
                >
                  <el-table-column label="用户名称" prop="order_sn" />
                  <el-table-column label="区域" prop="order_sn" />
                  <el-table-column label="订单数量" prop="order_sn" />
                  <el-table-column label="下单金额" prop="order_sn" />
                  <el-table-column label="配送金额" prop="order_sn" />
                  <el-table-column label="体积（m³）" prop="order_sn" />
                  <el-table-column label="重量（t）" prop="order_sn" />
                  <el-table-column label="车辆" prop="order_sn" />
                  <el-table-column label="配送状态" prop="order_sn">
                    <template>配送中：已完成</template>
                  </el-table-column>
                </el-table>
              </template>
            </el-table-column>

            <el-table-column
              label="线路名称"
              prop="name"
              :show-overflow-tooltip="true"
            />
            <el-table-column
              label="用户数量"
              prop="name"
              :show-overflow-tooltip="true"
            />
            <el-table-column
              label="订单数量"
              prop="name"
              :show-overflow-tooltip="true"
            />
            <el-table-column
              label="总体积（m³）"
              prop="name"
              :show-overflow-tooltip="true"
            />
            <el-table-column
              label="总重量（t）"
              prop="name"
              :show-overflow-tooltip="true"
            />
            <el-table-column
              label="配送中"
              prop="name"
              :show-overflow-tooltip="true"
            />
            <el-table-column
              label="配送完成"
              prop="name"
              :show-overflow-tooltip="true"
            />
            <el-table-column
              label="车辆数量"
              prop="name"
              :show-overflow-tooltip="true"
            />
            <el-table-column
              label="配送进度"
              prop="name"
              :show-overflow-tooltip="true"
              width="220"
            >
              <template>
                <el-progress
                  :text-inside="true"
                  :stroke-width="15"
                  :percentage="15"
                  status="success"
                  color="#03A98E"
                  style="width: 100%"
                ></el-progress
              ></template>
            </el-table-column>
          </el-table>
        </div>
        <div class="main_page boxdq">
          <div></div>
          <!-- 分页 -->
          <div class="main_page_r">
            <el-pagination
              :current-page="current.page"
              :page-sizes="[20, 30, 50, 100]"
              :page-size="limit"
              layout="total, sizes, prev, pager, next, jumper"
              :total="totalCount"
              @size-change="changeLimit"
              @current-change="changePage"
            />
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import {
  line_index,
  line_add,
  line_edit,
  line_delete,
  line_confirmDelete,
} from "@/api/distribution/distributionLine";
import rules from "@/rules/distribution/distributionLine";
import { apiUrl, objKeySort, Md5 } from "@/utils/public";
import { parseTime } from "@/utils/index";

export default {
  components: {},
  data() {
    return {
      parseTime,
      // 增加和编辑
      info: {
        title: "",
      },
      type: 0,
      id: 0,
      addedFormVisible: false,
      // 搜索
      form: {
        line: "",
        send_time: parseTime(new Date(), "{y}-{m}-{d}"),
      },
      // 验证
      rules,
      // 分页
      current: {
        page: 1,
        per_page: 20,
      },
      limit: 20,
      totalCount: 1,
      // 列表数据
      list: {
        list: {
          data: [
            {
              name: "李四",
              order_list: [{ order_sn: "张三" }],
            },
          ],
        },
      },
      listLoading: false,
    };
  },
  methods: {
    // 搜索
    getArticleList() {
      this.current.page = 1;
      this.line_index();
    },

    // 分页
    changeLimit(pageSize) {
      this.current.per_page = pageSize;
      this.line_index();
    },
    changePage(page) {
      this.current.page = page;
      this.line_index();
    },
    // 列表
    line_index() {
      this.listLoading = true;
      let data = Object.assign(
        apiUrl().name,
        JSON.parse(JSON.stringify(this.form)),
        this.current
      );
      line_index(data).then((res) => {
        this.listLoading = false;
        if (res.errcode == 0) {
          this.list = res.data;
          this.totalCount = res.data.list.total;
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
  },
  created() {
    // 列表
    // this.line_index();
  },
};
</script>
<style lang="scss" scoped>
.mainor_form form {
  width: calc(100% - 120px);
}
</style>
